package ui;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import util.Settings;

/**
 * Credits menu.
 * @author VincentLy
 */
public class Credits extends BasicGameState{

	private CustomButton back;	
	private String s1 = "Credits + Acknowledgements";
	private String s2 = "Vincent Ly";
	private String s3 = "Belinda Li";
	private String s4 = "John Shi";
	private float ex,ey = -1;

	public Credits(){
		super();
		back = new CustomButton(Settings.screenX/2-Settings.buttonX/2,Settings.screenY-Settings.buttonY*2,"Back",'b');
	}	

	/**
	 * Initialization not needed yet.
	 * @author VincentLy
	 */
	public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {}

	/**
	 * Checks to see if user is finished with the credits.
	 * @author VincentLy
	 */
	public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
		Input i = gc.getInput();
		ex = i.getMouseX();
		ey = i.getMouseY();
		if(back.contains(ex,ey)){
			back.setOn(true);
			if(i.isMousePressed(Input.MOUSE_LEFT_BUTTON))
				sbg.enterState(Settings.smID);
		}	
		else
			back.setOn(false);
	}

	/**
	 * Draws the text and buttons.
	 * @author VincentLy
	 */
	public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
		g.setAntiAlias(true);
		g.setBackground(Settings.bg);
		g.setLineWidth(1);
		g.setColor(Settings.screenText);
		g.drawString(s1,(Settings.screenX-g.getFont().getWidth(s1))/2,g.getFont().getHeight(s1));
		g.drawString(s2,(Settings.screenX-g.getFont().getWidth(s2))/2,200);
		g.drawString(s3,(Settings.screenX-g.getFont().getWidth(s3))/2,300);
		g.drawString(s4,(Settings.screenX-g.getFont().getWidth(s4))/2,400);
		back.draw(g);
	}

	/**
	 * @return id
	 * @author VincentLy
	 */
	public int getID() {return Settings.cID;}
}
